from sqlalchemy.future import select

from app.config import db
from app.model import Users, Person


class UserService:
    @staticmethod
    async def get_user_profile(phone_number: str):
        query = (
            select(
                Users.phone_number,
                Person.name,
                Person.sex,
                Person.profile,
                Person.email,  # Added this field
                Person.subject_type,  # Added this field
                Person.exam_province  # Added this field
            )
            .join_from(Users, Person)
            .where(Users.phone_number == phone_number)
        )
        return (await db.execute(query)).mappings().one()
